﻿using System;
using System.Text;

namespace MyFastDataSourceBind
{
/// <summary>
/// 参数列表类型
/// </summary>
[Serializable()]
public class XDBParameterInfoList : System.Collections.CollectionBase
{
    /// <summary>
    /// 初始化对象
    /// </summary>
    public XDBParameterInfoList()
    {
    }

    /// <summary>
    /// 获得指定序号处的参数信息对象
    /// </summary>
    /// <param name="index">序号</param>
    /// <returns>参数信息对象</returns>
    public XDBParameterInfo this[int index]
    {
        get { return (XDBParameterInfo)this.List[index]; }
    }

    /// <summary>
    /// 获得指定名称的参数信息对象
    /// </summary>
    /// <param name="name">指定的参数名</param>
    /// <returns>获得的参数信息对象</returns>
    public XDBParameterInfo this[string name]
    {
        get
        {
            foreach (XDBParameterInfo p in this)
            {
                if (string.Compare(p.Name, name, true) == 0)
                {
                    return p;
                }
            }
            return null;
        }
    }

    /// <summary>
    /// 添加参数
    /// </summary>
    /// <param name="p">参数对象</param>
    /// <returns>新参数在列表中的序号</returns>
    public int Add(XDBParameterInfo p)
    {
        return this.List.Add(p);
    }
    /// <summary>
    /// 添加参数
    /// </summary>
    /// <param name="Name">参数名称</param>
    /// <returns>新增的参数对象</returns>
    public XDBParameterInfo Add(string Name)
    {
        XDBParameterInfo p = new XDBParameterInfo();
        p.Name = Name;
        this.List.Add(p);
        return p;
    }
    /// <summary>
    /// 添加参数
    /// </summary>
    /// <param name="Name">参数名</param>
    /// <param name="Value">参数值</param>
    /// <returns>新增的参数对象</returns>
    public XDBParameterInfo Add(string Name, object Value)
    {
        XDBParameterInfo p = new XDBParameterInfo();
        p.Name = Name;
        p.Value = Value;
        this.List.Add(p);
        return p;
    }
    /// <summary>
    /// 删除参数
    /// </summary>
    /// <param name="p">参数对象</param>
    public void Remove(XDBParameterInfo p)
    {
        this.List.Remove(p);
    }
}
}
